<?php

use think\migration\Migrator;
use think\migration\db\Column;

class CreateTableCategory extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function up()
    {
        $this->execute("CREATE TABLE `f_category` (
            `cid` int(11) NOT NULL AUTO_INCREMENT,
            `pid` int(11) DEFAULT '0',
            `name` varchar(45) NOT NULL,
            `english_name` varchar(45) DEFAULT NULL,
            `intro` text,
            `images` text,
            `cover` varchar(145) DEFAULT NULL COMMENT '封面',
            `redirect` enum('yes','no') DEFAULT 'no',
            `redirect_url` varchar(145) DEFAULT NULL,
            `status` varchar(45) DEFAULT 'normal' COMMENT '状态',
            `model` varchar(45) DEFAULT 'common' COMMENT '数据模型',
            `remark` text,
            PRIMARY KEY (`cid`)
          ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='内容分类';");
    }
    public function down()
    {
        $this->execute("drop table `f_category`;");
    }
}
